﻿@inherits FilterBase

<Select Items="@Items" @bind-Value="@Value" OnSelectedItemChanged="_ => OnFilterValueChanged()"></Select>

@code {
    private List<SelectedItem> Items { get; set; } = new List<SelectedItem>();

    private int Value = 10;

    /// <summary>
    /// OnInitialized 方法
    /// </summary>
    protected override void OnInitialized()
    {
        base.OnInitialized();

        if (TableFilter != null) TableFilter.ShowMoreButton = false;

        Items.AddRange(new SelectedItem[]
        {
            new SelectedItem { Value = "10", Text = "大于 10" },
            new SelectedItem { Value = "50", Text = "大于 50" },
            new SelectedItem { Value = "100", Text = "大于 100" }
        });
    }

    /// <summary>
    /// 重置过滤条件方法
    /// </summary>
    public override void Reset()
    {
        Value = 10;

        StateHasChanged();
    }

    /// <summary>
    /// 生成过滤条件方法
    /// </summary>
    /// <returns></returns>
    public override IEnumerable<FilterKeyValueAction> GetFilterConditions()
    {
        var filters = new List<FilterKeyValueAction>();
        filters.Add(new FilterKeyValueAction()
        {
            FieldKey = FieldKey,
            FieldValue = Value,
            FilterAction = FilterAction.GreaterThan
        });
        return filters;
    }
}
